package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30)"json:"username"`
	Password string `gorm:"type:varchar(32)"json:"password"`
	Tel      string `gorm:"type:varchar(30)"json:"tel"`
}
type Real struct {
	gorm.Model
	UserId   int    `gorm:"type:int"json:"userId"`
	Name     string `gorm:"type:varchar(30)"json:"name"`
	Idnumber string `gorm:"type:char(18)"json:"idnumber"`
}
type Note struct {
	gorm.Model
	Title   string `gorm:"type:varchar(30)"json:"title"`
	Address string `gorm:"type:varchar(30)"json:"address"`
	NoteId  int    `gorm:"type:int"json:"noteId"`
}
type Like struct {
	gorm.Model
	NoteId int `gorm:"type:int"json:"noteId"`
	UserId int `gorm:"type:int"json:"userId"`
}

// 实名认证
func (real *Real) GetName() error {
	return DB.Where("user_id=?", real.UserId).Limit(1).Find(&real).Error
}

func (real *Real) AddUser() error {
	return DB.Create(&real).Error
}
